#ifndef _RADIAN_CAMERA_CONTROLLER_H_
#define _RADIAN_CAMERA_CONTROLLER_H_

#include "RadianCommon.h"
#include "math/vector3.h"
#include <QtGui>
/* Simple class to implement all the control styles. 
*/
class RadianEditorController : public QObject
{
	Q_OBJECT

public:
	RadianEditorController(Ogre::Camera* camera, QWidget* parentWidget,RadianRenderWnd* parentRenderWindow);
	virtual ~RadianEditorController();

	/* Browser mode.
	*/
	void SetBrowserMode(RadianBrowserMode browserMode) { mRadianBrowserMode = browserMode;} 
	RadianBrowserMode GetBrowserMode() { return mRadianBrowserMode;}

	/* Move along the axis.
	*/
	virtual void MoveRelative(float delta);

	/* Move the camera.
	*/
	virtual void MoveDelta(const Math::Vector3& delta);

	/* Yaw the camera.
	*/
	virtual void Yaw(float delta);

	/* Pitch the camera.
	*/
	virtual void Pitch(float delta);

	/* Focus to scene node.
	*/
	virtual void LockSceneNode(const Ogre::String& sceneNodeName);

	/* We need this because 
	*/
	virtual void NotifyCamera(Ogre::Camera* camera);

	/* Focus to scene node.
	*/
	virtual void FocusTo(Ogre::SceneNode* targeNode);

	/* Camera lock option.
	*/
	void SetLock(bool isLock) { mIsLock = isLock;}
	bool GetLock() { return mIsLock; }

	/* Update the controller.
	*/
	virtual void Update(float timeElapsed);

	/* Resize event.
	*/
	virtual void OnResize(QResizeEvent* evt);

	/* On key press.
	*/
	virtual void OnKeyPress(QKeyEvent* evt);

	/* On key press.
	*/
	virtual void OnKeyRelease(QKeyEvent* evt);

	/* On mouse move.
	*/
	virtual void OnMouseMove(QMouseEvent* evt);

	/* On mouse press.
	*/
	virtual void OnMousePress(QMouseEvent* evt);

	/* On mouse press.
	*/
	virtual void OnMouseRelease(QMouseEvent* evt);

	/* On key press.
	*/
	virtual void OnMouseDoublePress(QMouseEvent* evt);

	/* On mouse wheel.
	*/
	virtual void OnMouseWheel(QWheelEvent* evt);

	/* On focus lost.
	*/
	virtual void OnLostFocus(QFocusEvent* evt);

	/* On paint.
	*/
	virtual void OnPaint(QPaintEvent* evt);

	/* Event handling.
	*/
	virtual bool eventFilter(QObject *target, QEvent *event);

	/* Get selected scene node.
	*/
	Ogre::SceneNode* GetSelectedSceneNode();

	/* Get selected scene nodes.
	*/
	const SceneNodeList& GetSelectedSceneNodes();

	/* Get parent radian render wnd;
	*/
	RadianRenderWnd* GetParentRenderWnd();

	/* Get parent widget.
	*/
	QWidget* GetParentWidget();


protected:
	Ogre::Camera* mTargetCamera;					// target camera.
	RadianBrowserMode mRadianBrowserMode;			// browser mode.
	bool mIsLock;									// is locked.
	Ogre::String mLockedNodeName;					// locked scene node.
	RadianBrowserSenstive mRadianBrowserSenstive;	// browser senstive.
	QPointF mLastLeftMousePos;						// last mouse position.
	QPointF mLastRightMousePos;						// last mouse position.
	QWidget* mParentWidget;							// parent widget.
	RadianRenderWnd* mParentRenderWindow;			// parent render window.
	RadianEditMode mEditMode;						// current edit mode.
	SceneNodeList mSelectedNodes;					// all selected nodes.
	Ogre::SceneNode* mSelectedNode;					// selected node.
};
#endif